package com.ingeniouscamel.jsf2;

import java.util.List;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class AjaxEmployeeBean {
	private EmployeeService employeeService = new EmployeeService();

	private String selectedDept;
	private List<Employee> searchResults;

	public String getSelectedDept() {
		return selectedDept;
	}

	public void setSelectedDept(String selectedDept) {
		this.selectedDept = selectedDept;
	}

	public List<Employee> getSearchResults() {
		return searchResults;
	}	
	
	public String performSearch() {
		if (selectedDept.equals("All")  ) {
			searchResults = employeeService.getAllEmployees();
		} else {
			searchResults = employeeService.getEmployeesByDept(selectedDept);
		}
		return null;
	}
}